export function timeDifference(timestamp) {
    const currentTime = new Date().getTime();
    const diff = currentTime - timestamp;
    const minute = 60 * 1000;
    const hour = 60 * minute;
    const day = 24 * hour;
    const month = 30 * day; // 使用30天作为一个大概的月计算，实际情况更复杂，这里简化处理

    if (diff < minute) {
        return '1分钟内';
    } else if (diff < hour) {
        return `${Math.floor(diff / minute)}分钟`;
    } else if (diff < day) {
        return `${Math.floor(diff / hour)}小时`;
    } else if (diff < month) {
        return `${Math.floor(diff / day)}天`;
    } else if (diff < 3 * month) {
        return `${Math.floor(diff / month)}月`;
    } else {
        return null;
    }
}

// 错误情况返回首页
export function gotoHome(){
	uni.showModal({
		title:"提示",
		content:"页面有误将返回首页",
		showCancel:false,
		success: (res) => {
			if(res.confirm){
				uni.reLaunch({
					url:"/pages/index/index"
				})
			}
		}
	})
}